<template>
  <Dialog :title="title" :loading="loading" :visible="visible" button-text="提交" :reveal="false" class="two-columns" @close="handleClose">
    <!-- 已收款详情 -->
    <el-row flex style="padding-bottom: 30px">
      <el-col :span="12">{{ currentRow.customerName }}（{{ currentRow.customerPhone | phoneHandle }}）</el-col>
      <el-col :span="12">会员号  {{ currentRow.customerCode }}</el-col>
      <el-col :span="12" class="margin-top">业务单类型  {{ currentRow.paymentType }}</el-col>
      <el-col :span="12" class="margin-top">业务单号  {{ currentRow.orderCode }}</el-col>
      <el-col :span="12" class="margin-top">开单人  {{ currentRow.drawer }}</el-col>
      <el-col :span="12" class="margin-top">开单时间  {{ currentRow.createdTime }}</el-col>
      <div class="margin-top clear">
        <ul v-if="currentRow.orderList && currentRow.orderList.length>0">
          <li class="detailed font-weight">
            商品清单：
          </li>
          <li v-for="(items,i) of currentRow.orderList" :key="i">
            <el-row v-if="currentRow.paymentType !== '充值单'" style="width:100%">
              <el-row type="flex">
                <el-col :span="20" class="product">
                  <el-button class="bg" type="text">{{ items.productAttrib.split("类")[0] }}</el-button><span style="margin-left:10px;line-height:30px">{{ items.name || items.projectName || items.dataName }}</span>
                  <p style="margin:0px 10px;">{{ items.printName }}</p>
                </el-col>
                <el-col :span="2" :offset="2">
                  x {{ items.contentCount }}
                </el-col>
              </el-row>
              <el-row v-if="items.productAttrib !== '套餐类'" class="grey" type="flex">
                <el-col :span="20">
                  <span>规格：{{ items.specl }}</span>
                  <span>单位：{{ items.unit }}</span>
                  <span v-if="items.type === '项目'">使用次数：{{ items.usageCount }}</span>
                </el-col>
              </el-row>
              <el-row type="flex" class="price">
                <el-col :span="12">
                  售价：￥{{ items.price }}
                </el-col>
                <el-col :span="10">
                  折扣率：{{ items.discountRate?items.discountRate:100 }}%
                </el-col>
                <el-col :span="8" :offset="8">
                  折后价：￥{{ items.discountPrice?items.discountPrice:items.price }}
                </el-col>
              </el-row>
            </el-row>
            <el-row v-if="currentRow.paymentType === '充值单'" style="width:100%">
              <el-row type="flex">
                <el-col :span="20" class="product">
                  <el-button class="bg" type="text">{{ items.productAttrib.split("类")[0] }}</el-button><span style="margin-left:10px;line-height:30px">{{ items.contentType }}</span>
                  <p style="margin:0px 10px;">{{ items.printName }}</p>
                </el-col>
                <el-col :span="2" :offset="2">
                  x 1
                </el-col>
              </el-row>
              <el-row type="flex" class="price">
                <el-col :span="6">
                  售价：￥{{ items.price }}
                </el-col>
              </el-row>
            </el-row>
          </li>
        </ul>
      </div>
      <el-col :span="24" class="margin-top">收款类型<span class="pull-right">{{ currentRow.payType }}</span></el-col>
      <el-col :span="24" class="margin-top">收款金额<span class="pull-right">￥{{ currentRow.orderAmount }}</span></el-col>
      <el-col v-if="currentRow.paymentType !== '充值单'" :span="24" class="margin-top">使用余额(可使用￥{{ currentRow.capital }})
        <span class="pull-right">-￥{{ currentRow.residualAmount }}<i class="el-icon-arrow-right" /></span>
      </el-col>
      <el-col :span="24" class="margin-top"><span class="pull-right">应收款：<span class="font-color">￥{{ currentRow.actualAmount }}</span></span></el-col>
      <el-col :span="24" class="margin-top font-weight">收款</el-col>
      <div v-if="currentRow.paymentStatu !== '已取消'">
        <el-col v-for="(item,index) in currentRow.logList" v-show="item.payType !== '余额支付'" :key="index" :span="24" class="margin-top">{{ item.payType }}<span class="pull-right">{{ item.payAmount }}</span></el-col>
        <el-col :span="24" class="margin-top"><span class="pull-right">实收款：<span class="font-color">￥{{ currentRow.actualAmount }}</span></span></el-col>
        <el-col class="margin-top">备注  {{ currentRow.remark }}</el-col>
        <el-col :span="12" class="margin-top">经办人  {{ currentRow.operator }}</el-col>
        <el-col :span="12" class="margin-top">收款时间  {{ currentRow.collectionTime }}</el-col>
      </div>
      <div v-if="currentRow.paymentStatu === '已取消'">
        <el-col class="margin-top">状态  {{ currentRow.paymentStatu }}</el-col>
        <el-col :span="12" class="margin-top">取消人  {{ currentRow.operator }}</el-col>
        <el-col :span="12" class="margin-top">取消时间  {{ currentRow.collectionTime }}</el-col>
      </div>
    </el-row>
  </Dialog>
</template>
<script>
import Dialog from "@/components/Dialog";
export default {
  filters: {
    phoneHandle(val) {
      if (!val) return '';
      let phone = "";
      phone = val.substring(0, 3) + "****" + val.substring(val.length - 4, val.length);
      return phone;
    },
  },
  components: {
    Dialog,
  },
  props: {
    currentRow: {
      type: Object,
      default: () => ({}),
    },
    visible: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      loading: false,
      datas: {},
      tableData: [{ id: 0, mode: "", money: 0 }],
      receivables: 0, // 应收款
      paidIn: 0, // 实收款
      paymentList: [{ id: 0, value: "支付宝" }, { id: 1, value: "微信" }, { id: 2, value: "现金" }, { id: 3, value: "银联" }, { id: 4, value: "POS" }, { id: 5, value: "其他" }],
      balance: 0,
      remark: "",
      title: "",
    };
  },
  watch: {
    currentRow: {
      handler(val) {
        this.title = val.paymentType + "详情";
      },
      deep: true,
    },
  },
  methods: {
    handleClose() {
      this.$emit('close');
    },
  },
};
</script>
<style lang="scss" scoped>
.pull-right{
  float: right;
}
.font-color{
  color:#FF6600;
}
.button-color{
  color:#0099FF;
  border-color:#0099FF;
}
.clear{
  clear: both;
}
.detailed{
    margin: 15px 0;
  }
  .el-col-offset-8,.el-col-offset-2 {
  .el-button {
    margin-top: 15px;
    width: 100%;
    height: 40px;
  }
}
/deep/.el-form-item__content{
  margin-left: 50px !important;
}
  .span{
    color: #ff6600;
  }
  .grey{
    color: #aaaaaa;
  }
  .bg{
    background: rgba(211,223,247,0.7);
    width: 50px;
    height: 30px;
    text-align: center;
    border-radius: 10px;
    color: #666;
  }
  .product{
    display: flex;
  }
  .price{
    border-bottom: 1px solid #797979;
    padding-bottom: 10px;
    .el-col{
      display: flex;
    }
  }
  .el-col,.el-col-12{
    line-height: 40px;
  }
  li{
    display: flex;
    margin-top: 5px;
  }
  .detailed{
    margin: 15px 0;
    padding-top: 14px;
  }
  div>span{
    margin-right: 25px;
  }
  li{
      margin-top: 10px;
  }
  .font-weight{
    font-weight: bold;
  }
</style>
